package cn.edu.scau.cmi.yanweijie.interProgramming;

import java.util.ArrayList;
import java.util.List;

public class Marshal {

    private static int MAX_COUNT = 10;

    private static int objCount = 0;

    private static List<String> marshal_list = new ArrayList<>();

    private static Marshal instance = null;

    public String getName() {
        return name;
    }

    private String name;

    private Marshal(String name) {
        this.name=name;
    }

    public static Marshal getInstance(String name) {

        if (objCount++ < MAX_COUNT || (instance == null && !name.equals(null))) {

            marshal_list.add(name);
            instance = new Marshal(name);
        }

        return instance;
    }
}
